﻿using Prism.Commands;
using Prism.Mvvm;
using UsingCompositeCommands.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ModuleA.ViewModels
{
    public class TabViewModel : BindableBase
    {
        private string _message;
        public string Message
        {
            get { return _message; }
            set { SetProperty(ref _message, value); }
        }
        private string _title="Tab";
        public string Title
        {
            get => _title;
            set => SetProperty(ref _title, value);
        }
        private bool _canUpadte=true;
        public bool CanUpdate
        {
            get => _canUpadte;
            set => SetProperty(ref _canUpadte, value);
        }
        private string _updatedText;
        public string UpdatedText
        {
            get => _updatedText;
            set => SetProperty(ref _updatedText, value);
        }
        private IApplicationCommands _applicationCommands;
        public DelegateCommand UpdateCommand { get; private set; }
        public TabViewModel(IApplicationCommands applicationCommands)
        {
            _applicationCommands = applicationCommands;
            UpdateCommand = new DelegateCommand(() => UpdatedText = $"Updated: {DateTime.Now}").ObservesCanExecute(()=>CanUpdate);
            _applicationCommands.SaveCommand.RegisterCommand(UpdateCommand);
        }
    }
}
